import estoque.model.*;
import estoque.view.*;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/* @author Vinicius */

public class JFControle extends javax.swing.JFrame {
    
    static  ArrayList<Item> itens = new ArrayList<>();
    static  ArrayList<Cliente> clientes = new ArrayList<>();
    static  ArrayList<Compra> compras = new ArrayList<>();
    static  ArrayList<Venda> vendas = new ArrayList<>();
    
    public JFControle() {
        initComponents();
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BtnItem = new javax.swing.JToggleButton();
        BtnCliente = new javax.swing.JToggleButton();
        BtnCompra = new javax.swing.JToggleButton();
        BtnVenda = new javax.swing.JToggleButton();
        BtnItensEstoque = new javax.swing.JToggleButton();
        BtnVendasClientes = new javax.swing.JButton();
        BtnVendaItem = new javax.swing.JButton();
        BtnRelFinanceiro = new javax.swing.JToggleButton();
        BtnGraficoVendaItens = new javax.swing.JButton();
        BtnGraficoVendaCliente = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Controle de Estoque");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        BtnItem.setText("Item");
        BtnItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnItemActionPerformed(evt);
            }
        });

        BtnCliente.setText("Cliente");
        BtnCliente.setPreferredSize(new java.awt.Dimension(55, 23));
        BtnCliente.setRequestFocusEnabled(false);
        BtnCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnClienteActionPerformed(evt);
            }
        });

        BtnCompra.setLabel("Compra");
        BtnCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnCompraActionPerformed(evt);
            }
        });

        BtnVenda.setText("Venda");
        BtnVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnVendaActionPerformed(evt);
            }
        });

        BtnItensEstoque.setText("Itens em Estoque");
        BtnItensEstoque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnItensEstoqueActionPerformed(evt);
            }
        });

        BtnVendasClientes.setText("Vendas por Cliente");
        BtnVendasClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnVendasClientesActionPerformed(evt);
            }
        });

        BtnVendaItem.setText("Vendas por Item");
        BtnVendaItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnVendaItemActionPerformed(evt);
            }
        });

        BtnRelFinanceiro.setText("Relatório Financeiro");
        BtnRelFinanceiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnRelFinanceiroActionPerformed(evt);
            }
        });

        BtnGraficoVendaItens.setText("Gráfico Venda de Itens");
        BtnGraficoVendaItens.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnGraficoVendaItensActionPerformed(evt);
            }
        });

        BtnGraficoVendaCliente.setText("Gráfico Venda por Clientes");
        BtnGraficoVendaCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnGraficoVendaClienteActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Cadastro:");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Relátorio:");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setText("Controle de Estoque");
        jLabel3.setPreferredSize(new java.awt.Dimension(115, 20));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(267, 267, 267)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BtnItem, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BtnItensEstoque, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(BtnGraficoVendaItens, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(BtnCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(BtnVendaItem, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(35, 35, 35)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(BtnCompra, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)
                                    .addComponent(BtnVendasClientes, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
                                .addGap(20, 20, 20)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(BtnVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(BtnRelFinanceiro, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(BtnGraficoVendaCliente))))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41)
                .addComponent(jLabel1)
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnItem, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnCompra, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(55, 55, 55)
                .addComponent(jLabel2)
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnItensEstoque, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnVendaItem, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnVendasClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnRelFinanceiro, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnGraficoVendaItens, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BtnGraficoVendaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(92, Short.MAX_VALUE))
        );

        BtnItem.getAccessibleContext().setAccessibleName("BtnItem");
        BtnCliente.getAccessibleContext().setAccessibleName("BtnCliente");
        BtnCompra.getAccessibleContext().setAccessibleName("BtnCompra");
        BtnVenda.getAccessibleContext().setAccessibleName("BtnVenda");

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void BtnItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnItemActionPerformed
         new JFItem().setVisible(true);
    }//GEN-LAST:event_BtnItemActionPerformed

    private void BtnClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnClienteActionPerformed
         new JFCliente().setVisible(true);
    }//GEN-LAST:event_BtnClienteActionPerformed

    private void BtnCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnCompraActionPerformed
         new JFCompra().setVisible(true);
    }//GEN-LAST:event_BtnCompraActionPerformed

    private void BtnVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnVendaActionPerformed
         new JFVenda().setVisible(true);
    }//GEN-LAST:event_BtnVendaActionPerformed

    private void BtnItensEstoqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnItensEstoqueActionPerformed
       new JFRelItensEstoque().setVisible(true);
    }//GEN-LAST:event_BtnItensEstoqueActionPerformed

    private void BtnVendasClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnVendasClientesActionPerformed
        new JFRelVendaItemCliente().setVisible(true);
    }//GEN-LAST:event_BtnVendasClientesActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        Arquivo.chamaGravacao();
        dispose();
    }//GEN-LAST:event_formWindowClosing

    private void BtnVendaItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnVendaItemActionPerformed
        new JFRelVendaItem().setVisible(true);
    }//GEN-LAST:event_BtnVendaItemActionPerformed

    private void BtnRelFinanceiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnRelFinanceiroActionPerformed
        new JFRelFinanceiro().setVisible(true);
    }//GEN-LAST:event_BtnRelFinanceiroActionPerformed

    private void BtnGraficoVendaItensActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnGraficoVendaItensActionPerformed
        new JFGraficoRelVendaItens().setVisible(true);
    }//GEN-LAST:event_BtnGraficoVendaItensActionPerformed

    private void BtnGraficoVendaClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnGraficoVendaClienteActionPerformed
       new JFGraficoVendaCliente().setVisible(true);
    }//GEN-LAST:event_BtnGraficoVendaClienteActionPerformed
 
    /**
     * @param args the command line arguments
     * @throws java.io.FileNotFoundException
     */
    public static void main(String args[]) throws FileNotFoundException, IOException {
         Arquivo.verificaArquivo();
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JFControle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JFControle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JFControle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JFControle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

                new JFControle().setVisible(true);
            }
        });

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton BtnCliente;
    private javax.swing.JToggleButton BtnCompra;
    private javax.swing.JButton BtnGraficoVendaCliente;
    private javax.swing.JButton BtnGraficoVendaItens;
    private javax.swing.JToggleButton BtnItem;
    private javax.swing.JToggleButton BtnItensEstoque;
    private javax.swing.JToggleButton BtnRelFinanceiro;
    private javax.swing.JToggleButton BtnVenda;
    private javax.swing.JButton BtnVendaItem;
    private javax.swing.JButton BtnVendasClientes;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables

}
